package cn.webrx;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Ex7 {
    public static void main(String[] args) {
        //try with java 1.7 新语法
        try(FileWriter fw = new FileWriter("usr.txt");FileReader fr = new FileReader("user.txt")){
            fw.write("hello1\n");
            fw.write("hello2\n");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    public static void jio(String[] args) {
        FileWriter fw = null;
        try {
            fw = new FileWriter("user.txt");
            fw.write("hello 文件\n");
            fw.write("hello javademo。\n");
         } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                fw.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
